﻿using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using eShop.DataAccess.Entity;

namespace eShop.DataAccess
{
    public partial class UserDAL : BaseDAL
    {
        public static List<User> GetUserByUserName(string userName)
        {
            List<User> userList = new List<User>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("User_Custom_GetByUserName");
            db.AddInParameter(dbCommand, "UserName", DbType.String, userName);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                userList = GetEntitiesFromReader(dataReader);
            }
            return userList;
        }
    }
}
